package com.zmj.mobile.process;

import com.zmj.framework.exception.CustomException;
import com.zmj.mobile.enums.ExceptionEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author lzy
 * @since 2023-12-01
 */
@Slf4j
@Component
public class AuditServiceFactory {
    @Resource
    private Map<String, IAuditService> auditServiceMap;

    public IAuditService getAuditService(AuditServiceEnum auditServiceEnum) {
        if (auditServiceEnum == null || !auditServiceMap.containsKey(auditServiceEnum.getServiceName())) {
            throw new CustomException(ExceptionEnum.AUDIT_SERVICE_NOT_EXISTS);
        }
        return auditServiceMap.get(auditServiceEnum.getServiceName());
    }
}
